﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CiStatus.CiStatusAddIn.ViewModels
{
    public class DataModel : INotifyPropertyChanged
    {
       
        protected void SendPropertyChanged(string property)
        {
            if (_propertyChangedEvent != null) _propertyChangedEvent(this, new PropertyChangedEventArgs(property));
        }


        protected void NotifyProperty<TProperty>(Expression<Func<TProperty>> property)
        {
            var lambda = (LambdaExpression)property; MemberExpression memberExpression;
            if (lambda.Body is UnaryExpression)
            {
                var unaryExpression = (UnaryExpression)lambda.Body;
                memberExpression = (MemberExpression)unaryExpression.Operand;
            }
            else memberExpression = (MemberExpression)lambda.Body;
            SendPropertyChanged(memberExpression.Member.Name);
        }
    }
}
